<template>
	<declaration-from v-model="installFaultData" type="install" @submit="submit" />
</template>

<script>

import declarationFrom from '../components/declarationFrom.vue';
import createRow from '../components/createRow';
import { mapActions } from 'vuex';
export default {
	components: { declarationFrom },
	data() {
		return {
			installFaultData: { ...createRow }
		};
	},
	methods: {
		...mapActions('user', ['getInfo', 'install']),
		/**
		* @example 获取基础信息
		*/
		async getUserInfo() {
			uni.showLoading({ title: '查询中' });
			const [errMsg, info] = await this.$await(this.getInfo());
			uni.hideLoading();
			if (errMsg) {
				console.log('获取基础信息错误', errMsg)
				this.$u.toast('获取基础信息错误');
			}
		},
		/**
		 * @example 提交报装信息
		 * @returns {Object} 维修员信息
		 */
		async submit(installData) {
			console.log('提交报装信息', installData)
			const [err, res] = await this.$await(this.install(installData));
			if (err) return
			uni.redirectTo({
				url: '/pages/success/index'
			});
			// const { name } = res
			// uni.showModal({
			// 	title: '提交成功',
			// 	content: `亲爱的${name},师傅将在24小时内联系您,请耐心等待。`,
			// 	showCancel: false,
			// });
		},
	},
	/**
	 * @example 加载基础信息
	 * @returns {Object} 基础信息
	 */
	created() {
		this.getUserInfo()
	},
};
</script>